package shc.graduation.http.query;

import org.litepal.crud.DataSupport;

import shc.graduation.bean.CodeInfo;

/**
 * Created by shuhuiChen on  2016/5/21  18:44.
 * Email ：shuhuiCSH@126.com
 */
public class CodeQuery extends BaseQuery<CodeInfo> {

    @Override
    public void query() {

        if (mStateEvent.group == 1) {
            mListModel = DataSupport.offset(mStateEvent.index * limit)
                    .limit(limit)
                    .order("time desc")
                    .find(CodeInfo.class, true);
        } else {
            mListModel = DataSupport.where("codegroup_id = ?", String.valueOf(mStateEvent.group + ""))
                    .offset(mStateEvent.index * limit)
                    .limit(limit)
                    .order("time desc")
                    .find(CodeInfo.class, true);
        }
        mStateEvent.model = mListModel;

        callBackSuccess(mStateEvent, "查询成功");
    }

}
